
export let baseChartMixin = {
  components: {

  },
  props: {
    settings: {
      type: Object,
      default() {
        return {}
      }
    },
    def: {
      type: Object,
      default() {
        return {
          columns: [],
          records: [],
        }
      }
    }
  },
  methods: {
    $_genPieOption(records = [], columns = [],) {

      let ret = {}

      let data = records.map(v => {
        return {
          name: v[0],
          value: v[1]
        }
      })

      ret = {
        series: [
          {
            type: 'pie',
            // radius: '50%',
            data: data,

          }
        ]
      }

      return ret
    },
    $_genOption(records = [], columns = [],
                {type = 'line'} = {}) {
      let xAxis = records.map(v => v[0])

      // console.log(xAxis)

      let lines = []
      for (let i = 1; i < columns.length; i++) {
        let ret = {}
        ret.name = columns[i]
        ret.type = type
        ret.data = records.map(v => v[i])
        ret.smooth = true
        lines.push(ret)
      }

      return {
        xAxis: {
          type: 'category',
          data: xAxis,
        },
        yAxis: {
          type: 'value',
        },
        series: [
          ...lines
        ]
      }
    }
  },
}
